package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity.XuanquEntity;
import io.renren.modules.sys.service.XuanquService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-04-27 23:24:13
 */
@RestController
@RequestMapping("sys/xuanqu")
public class XuanquController {
    @Autowired
    private XuanquService xuanquService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:xuanqu:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = xuanquService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/lists")
    public R lists(@RequestParam Map<String, Object> params){
    List<XuanquEntity> list= xuanquService.listxuanqu(params);

        return R.ok().put("page", list);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:xuanqu:info")
    public R info(@PathVariable("id") Integer id){
        XuanquEntity xuanqu = xuanquService.getById(id);

        return R.ok().put("xuanqu", xuanqu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:xuanqu:save")
    public R save(@RequestBody XuanquEntity xuanqu){
        xuanquService.save(xuanqu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:xuanqu:update")
    public R update(@RequestBody XuanquEntity xuanqu){
        ValidatorUtils.validateEntity(xuanqu);
        xuanquService.updateById(xuanqu);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:xuanqu:delete")
    public R delete(@RequestBody Integer[] ids){
        xuanquService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
